﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Entity;
using OTA.Notification.BO.Dictionary;

namespace EZCRS.HCMS.Web.manage.setup
{
    public partial class company_add : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckModule(77);
            if (!Page.IsPostBack)
            {
                ddlTRAVEL_SECTOR.DataSource = new DictionaryBO().getAllDictionary("TVS", OTA.Notification.Common.DicType.Common, OTA.Notification.Common.LanguageType.English);
                ddlTRAVEL_SECTOR.DataTextField = "name";
                ddlTRAVEL_SECTOR.DataValueField = "value";
                ddlTRAVEL_SECTOR.DataBind();

                int id = CFun.RequestNumber("id");
                if (id > 0)
                {
                    HCRS_COMPANY company = new BllHCRS_COMPANY().getitem(id);
                    if (company != null)
                    {
                        CFun.bindpagedata<HCRS_COMPANY>(this, company);
                    }
                }
            }
        }

        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            HCRS_COMPANY company = new HCRS_COMPANY();

            CFun.getpagedata<HCRS_COMPANY>(company, this);
            company.LAST_UPDATE_TIME = DateTime.Now;
            company.UPDATE_USER_NAME = base.BasUserName;

            if (company.id == 0)
            {
                company.CREATE_TIME = DateTime.Now;
                company.CREATE_USER_NAME = base.BasUserName;
            }

            if(new BllHCRS_COMPANY().insertorupdateitem(company))
                Response.Write(CFun.AlertMeg(Resources.Site.LabAddressList + Resources.Site.SystemModifySuccess, "", "company.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }
    }
}
